home *** CD-ROM | disk | FTP | other *** search
- /************************************************************************/
- /* libroom.c */
- /* Library for room code */
- /************************************************************************/
-
- /************************************************************************/
- /* History */
- /* */
- /* 85Nov15 HAW Create. */
- /************************************************************************/
-
- #include "ctdl.h"
-
- /************************************************************************/
- /* Contents */
- /* */
- /* getRoom() load given room into RAM */
- /* putRoom() store room to given disk slot */
- /************************************************************************/
-
- struct aRoom roomBuf; /* Room buffer */
- extern struct rTable roomTab[MAXROOMS];/* RAM index */
- FILE *roomfl; /* Room file descriptor */
- int thisRoom = LOBBY; /* Current room */
-
- /************************************************************************/
- /* getRoom() */
- /************************************************************************/
- getRoom(rm)
- int rm;
- {
- long int s;
- long val;
-
- /* load room #rm into memory starting at buf */
- thisRoom = rm;
- s = rm * sizeof roomBuf;
- fseek(roomfl, s, 0);
-
- if (fread(&roomBuf, sizeof roomBuf, 1, roomfl) != 1) {
- crashout(" ?getRoom(): read failed//error or EOF!");
- }
- crypte(&roomBuf, sizeof roomBuf, rm);
- }
-
- /************************************************************************/
- /* putRoom() stores room in buf into slot rm in room.buf */
- /************************************************************************/
- putRoom(rm)
- int rm;
- {
- long int s;
-
- crypte(&roomBuf, sizeof roomBuf, rm);
- s = rm * sizeof roomBuf;
-
- fseek(roomfl, s, 0);
- if (fwrite(&roomBuf, sizeof roomBuf, 1, roomfl) != 1) {
- crashout("?putRoom() crash!//0 returned!!!");
- }
-
- crypte(&roomBuf, sizeof roomBuf, rm);
- }
-